package com.rx.util;

import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;

/**
 * SpringBean工具类
 * 
 * @author Renxin
 * 
 */
public class BeanUtils {

	/**
	 * 获取SpringBean
	 * 
	 * @param beanName
	 * @return
	 * @throws Exception
	 */
	public static Object getBean(String beanName) throws Exception {
		Object obj = null;
		try {
			WebApplicationContext wac = ContextLoader
					.getCurrentWebApplicationContext();
			obj = wac.getBean(beanName);
		} catch (Exception e) {
			throw e;
		}
		return obj;
	}

}
